home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / QuickTime™ VR 2.0 SDK / Documentation + Extras / Updated Interfaces / QuickDraw 3D 1.5 Interfaces / Interfaces / QD3DRenderer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-22  |  46.6 KB  |  1,442 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DRenderer.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Renderer types and routines                                   **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1996 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #ifndef QD3DRenderer_h
  15. #define QD3DRenderer_h
  16.  
  17. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  18.     #pragma once
  19. #endif  /*  PRAGMA_ONCE  */
  20.  
  21. #include "QD3DView.h"
  22. #include "QD3DSet.h"
  23.  
  24. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH 
  25.  
  26. /*
  27.  * the following gets around a problem in xlc with unsigned 32 bit enums 
  28.  * that have been defined in system header files
  29.  */
  30. #if defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  31.     #pragma options enum=small
  32. #endif
  33.  
  34. #include <Events.h>
  35.  
  36. /*
  37.  * reset to default after the system headers
  38.  */
  39. #if defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  40.     #pragma options enum=reset
  41. #endif
  42.  
  43. #endif /* WINDOW_SYSTEM_MACINTOSH */
  44.  
  45. #if defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  46.     #include "windows.h"
  47. #endif /* WINDOW_SYSTEM_WIN32 */
  48.  
  49. #if defined(THINK_C) || defined(__SC__)
  50.     #pragma options(!pack_enums, !align_arrays)
  51.     #pragma SC options align=power
  52. #elif defined(__MWERKS__)
  53.     #pragma enumsalwaysint on
  54.     #pragma align_array_members off
  55.     #pragma options align=native
  56. #elif defined(__PPCC__)
  57.     #pragma options align=power
  58. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  59.     #pragma options enum=int
  60. #endif
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif    /* __cplusplus */
  65.  
  66. /******************************************************************************
  67.  **                                                                             **
  68.  **                            User Interface Things                             **
  69.  **                                                                             **
  70.  *****************************************************************************/
  71.  
  72. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  73.  
  74. /*
  75.  *  A callback to an application's event handling code. This is needed to    
  76.  *  support movable modal dialogs. The dialog's event filter calls this      
  77.  *  callback with events it does not handle.                                 
  78.  *  If an application handles the event it should return kQ3True.            
  79.  *  If the application does not handle the event it must return kQ3False and 
  80.  *  the dialog's event filter will pass the event to the system unhandled.   
  81.  */
  82. typedef TQ3Boolean (QD3D_CALLBACK *TQ3MacOSDialogEventHandler)( 
  83.     EventRecord     event);
  84.  
  85. typedef struct TQ3DialogAnchor {
  86.     TQ3MacOSDialogEventHandler clientEventHandler;
  87. } TQ3DialogAnchor;
  88.  
  89. #elif defined(WINDOW_SYSTEM_WIN32) && WINDOW_SYSTEM_WIN32  
  90.  
  91. typedef struct TQ3DialogAnchor {
  92.     HWND    ownerWindow;    
  93. } TQ3DialogAnchor;
  94.  
  95. #else  /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  96.  
  97. typedef struct TQ3DialogAnchor {
  98.     void    notUsed;  /* place holder */
  99. } TQ3DialogAnchor;
  100.  
  101. #endif  /* ! WINDOW_SYSTEM_MACINTOSH && ! WINDOW_SYSTEM_WIN32 */
  102.  
  103.  
  104. /******************************************************************************
  105.  **                                                                             **
  106.  **                                Renderer Functions                             **
  107.  **                                                                             **
  108.  *****************************************************************************/
  109.  
  110. QD3D_EXPORT TQ3RendererObject QD3D_CALL Q3Renderer_NewFromType(
  111.     TQ3ObjectType            rendererObjectType);
  112.  
  113. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3Renderer_GetType(
  114.     TQ3RendererObject        renderer);
  115.  
  116. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  117.  
  118. /*
  119.  *    Non-blocking, flush all buffered graphics to rasterizer. May or
  120.  *    may not update the draw context.
  121.  *    
  122.  *    This function has been replaced by Q3View_Flush
  123.  */
  124. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_Flush(
  125.     TQ3RendererObject        renderer,
  126.     TQ3ViewObject            view);
  127.     
  128. /*
  129.  *    Blocking, flush all buffered graphics to rasterizer and update
  130.  *    draw context.
  131.  *    
  132.  *    This function has been replaced by Q3View_Sync
  133.  */
  134. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_Sync(
  135.     TQ3RendererObject        renderer,
  136.     TQ3ViewObject            view);
  137.     
  138. #endif  /*  QD3D_OBSOLETE  */
  139.  
  140. /*
  141.  *    Q3Renderer_HasModalConfigure
  142.  *        Determine if this renderer has a modal settings dialog.
  143.  *
  144.  *    Q3Renderer_ModalConfigure
  145.  *        Have the renderer pop up a modal dialog box to configure its settings.
  146.  *    dialogAnchor - is platform specific data passed by the client to support
  147.  *      movable modal dialogs. 
  148.  *    MacOS: this is a callback to the calling application's event handler.
  149.  *      The renderer calls this function with events not handled by the 
  150.  *      settings dialog. This is necessary in order to support movable modal 
  151.  *      dialogs. An application's event handler must return kQ3True if it 
  152.  *      handles the event passed to the callback or kQ3False if not. 
  153.  *      An application which doesn't want to support a movable modal configure
  154.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  155.  *    Win32: this is the HWND of the owning window (typically an application's
  156.  *      main window).
  157.  *  canceled - returns a boolean inditacating that the user canceled the 
  158.  *    dialog.
  159.  *      
  160.  */
  161. QD3D_EXPORT TQ3Boolean QD3D_CALL Q3Renderer_HasModalConfigure(
  162.     TQ3RendererObject        renderer);
  163.  
  164. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_ModalConfigure(
  165.     TQ3RendererObject        renderer, 
  166.     TQ3DialogAnchor         dialogAnchor, 
  167.     TQ3Boolean                *canceled);
  168.  
  169. /*
  170.  *    Q3Renderer_GetConfigurationData
  171.  *        Allows an application to collect private renderer configuration data
  172.  *      which it will then save. For example in a preference file or in a 
  173.  *        style template. An application should tag this data with the 
  174.  *        Renderer's object  name.
  175.  *    
  176.  *        if dataBuffer is NULL actualDataSize returns the required size in 
  177.  *        bytes of a data buffer large enough to store private data. 
  178.  *
  179.  *      bufferSize is the actual size of the memory block pointed to by 
  180.  *        dataBuffer
  181.  *
  182.  *        actualDataSize - on return the actual number of bytes written to the 
  183.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  184.  * 
  185.  */
  186. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_GetConfigurationData(
  187.     TQ3RendererObject        renderer, 
  188.     unsigned char            *dataBuffer, 
  189.     unsigned long            bufferSize,
  190.     unsigned long            *actualDataSize);
  191.  
  192. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_SetConfigurationData(
  193.     TQ3RendererObject        renderer, 
  194.     unsigned char            *dataBuffer, 
  195.     unsigned long            bufferSize);
  196.  
  197. #if defined(ESCHER_VER_FUTURE) && ESCHER_VER_FUTURE
  198.  
  199. /*
  200.  *    Q3Renderer_DeleteCaches
  201.  *    
  202.  *    Deletes any caches in a renderer created with 
  203.  *    Q3View_BeginRendererCache and Q3View_EndRendererCache that may be 
  204.  *    associated with this renderer.
  205.  */
  206. QD3D_EXPORT TQ3Status QD3D_CALL Q3Renderer_DeleteCaches(
  207.     TQ3RendererObject        renderer);
  208.  
  209. #endif  /*  ESCHER_VER_FUTURE  */
  210.  
  211.  
  212. /******************************************************************************
  213.  **                                                                             **
  214.  **                        Interactive Renderer Specific Functions                 **
  215.  **                                                                             **
  216.  *****************************************************************************/
  217.  
  218. /* 
  219.  *  CSG IDs attribute 
  220.  */
  221. #define kQ3AttributeTypeConstructiveSolidGeometryID \
  222.     Q3_OBJECT_TYPE('c','s','g','i')
  223.  
  224. #if defined(QD3D_OBSOLETE) && QD3D_OBSOLETE
  225.  
  226. #define kQ3AttributeType_ConstructiveSolidGeometryID \
  227.     kQ3AttributeTypeConstructiveSolidGeometryID
  228.     
  229. #endif  /*  QD3D_OBSOLETE  */
  230.  
  231. /* 
  232.  *  Object IDs, to be applied as attributes on geometries 
  233.  */
  234. #define kQ3SolidGeometryObjNone    -1
  235. #define kQ3SolidGeometryObjA     0
  236. #define kQ3SolidGeometryObjB     1
  237. #define kQ3SolidGeometryObjC     2
  238. #define kQ3SolidGeometryObjD     3
  239. #define kQ3SolidGeometryObjE     4
  240.  
  241. /* 
  242.  *  Possible CSG equations 
  243.  */
  244. typedef enum TQ3CSGEquation {
  245.     kQ3CSGEquationAandB            = (int)0x88888888,
  246.     kQ3CSGEquationAandnotB         = 0x22222222,
  247.     kQ3CSGEquationAanBonCad        = 0x2F222F22,
  248.     kQ3CSGEquationnotAandB        = 0x44444444,
  249.     kQ3CSGEquationnAaBorCanB    = 0x74747474
  250. } TQ3CSGEquation;
  251.  
  252. typedef enum TQ3HiddenSurfaceRemovalMode {
  253.     kQ3HiddenSurfaceRemovalMode_None,
  254.     kQ3HiddenSurfaceRemovalMode_Shallow,
  255.     kQ3HiddenSurfaceRemovalMode_Deep
  256. } TQ3HiddenSurfaceRemovalMode;
  257.  
  258. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetCSGEquation(
  259.     TQ3RendererObject        renderer,
  260.     TQ3CSGEquation            equation);
  261.  
  262. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetCSGEquation(
  263.     TQ3RendererObject        renderer,
  264.     TQ3CSGEquation            *equation);
  265.  
  266. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetPreferences(
  267.     TQ3RendererObject        renderer,
  268.     long                    vendorID,
  269.     long                    engineID);
  270.  
  271. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetPreferences(
  272.     TQ3RendererObject        renderer,
  273.     long                    *vendorID,
  274.     long                    *engineID);
  275.     
  276. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetDoubleBufferBypass(
  277.     TQ3RendererObject        renderer,
  278.     TQ3Boolean                bypass);
  279.  
  280. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetDoubleBufferBypass(
  281.     TQ3RendererObject        renderer,
  282.     TQ3Boolean                *bypass);
  283.  
  284. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetRAVEContextHints(
  285.     TQ3RendererObject        renderer,
  286.     unsigned long            RAVEContextHints);
  287.  
  288. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetRAVEContextHints(
  289.     TQ3RendererObject        renderer,
  290.     unsigned long            *RAVEContextHints);
  291.  
  292. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_SetRAVETextureFilter(
  293.     TQ3RendererObject        renderer,
  294.     unsigned long            RAVEtextureFilterValue);
  295.  
  296. QD3D_EXPORT TQ3Status QD3D_CALL Q3InteractiveRenderer_GetRAVETextureFilter(
  297.     TQ3RendererObject        renderer,
  298.     unsigned long            *RAVEtextureFilterValue);
  299.  
  300.  
  301. /******************************************************************************
  302.  **                                                                             **
  303.  **                            Renderer View Tools                                 **
  304.  **                                                                             **
  305.  **                    You may only call these methods from a plug-in             **
  306.  **                                                                             **
  307.  *****************************************************************************/
  308.  
  309. /*
  310.  *    Call by a renderer to call the user "idle" method, with progress 
  311.  *    information.
  312.  *    
  313.  *    Pass in (view, 0, n) on first call
  314.  *    Pass in (view, 1..n-1, n) during rendering
  315.  *    Pass in (view, n, n) upon completion
  316.  *    
  317.  *    Note: The user must have supplied an idleProgress method with 
  318.  *    Q3XView_SetIdleProgressMethod. Otherwise, the generic idle method is
  319.  *    called with no progress data. e.g. the Q3View_SetIdleMethod method
  320.  *    is called instead. (current and final are ignored, essentially.)
  321.  *
  322.  *    Returns kQ3Failure if rendering is cancelled.
  323.  */
  324. QD3D_EXPORT TQ3Status QD3D_CALL Q3XView_IdleProgress(
  325.      TQ3ViewObject        view,
  326.      unsigned long        current,
  327.      unsigned long        completed);
  328.  
  329. /*
  330.  *    Called by an asynchronous renderer when it completes a frame.
  331.  */
  332. QD3D_EXPORT TQ3Status QD3D_CALL Q3XView_EndFrame(
  333.      TQ3ViewObject        view);
  334.  
  335.  
  336. /******************************************************************************
  337.  **                                                                             **
  338.  **                            Renderer AttributeSet Tools                         **
  339.  **                                                                             **
  340.  **                    You may only call these methods from a plug-in             **
  341.  **                                                                             **
  342.  *****************************************************************************/
  343.  
  344. /*
  345.  *    Faster access to geometry attribute sets.
  346.  *    
  347.  *    Returns pointer to INTERNAL data structure for elements and attributes
  348.  *    in an attributeSet, or NULL if no attribute exists.
  349.  *    
  350.  *    For attributes of type kQ3AttributeType..., the internal data structure
  351.  *    is identical to the data structure used in Q3AttributeSet_Add.
  352.  */
  353. QD3D_EXPORT void *QD3D_CALL Q3XAttributeSet_GetPointer(
  354.      TQ3AttributeSet            attributeSet,
  355.      TQ3AttributeType        attributeType);
  356.      
  357. #define kQ3XAttributeMaskNone                        \
  358.     0L
  359.  
  360. #define kQ3XAttributeMaskSurfaceUV                    \
  361.     (1 << (kQ3AttributeTypeSurfaceUV - 1))
  362.  
  363. #define kQ3XAttributeMaskShadingUV                    \
  364.     (1 << (kQ3AttributeTypeShadingUV - 1))
  365.  
  366. #define kQ3XAttributeMaskNormal                        \
  367.     (1 << (kQ3AttributeTypeNormal - 1))
  368.  
  369. #define kQ3XAttributeMaskAmbientCoefficient            \
  370.     (1 << (kQ3AttributeTypeAmbientCoefficient - 1))
  371.  
  372. #define kQ3XAttributeMaskDiffuseColor                \
  373.     (1 << (kQ3AttributeTypeDiffuseColor - 1))
  374.  
  375. #define kQ3XAttributeMaskSpecularColor                \
  376.     (1 << (kQ3AttributeTypeSpecularColor - 1))
  377.  
  378. #define kQ3XAttributeMaskSpecularControl            \
  379.     (1 << (kQ3AttributeTypeSpecularControl - 1))
  380.  
  381. #define kQ3XAttributeMaskTransparencyColor            \
  382.     (1 << (kQ3AttributeTypeTransparencyColor - 1))
  383.  
  384. #define kQ3XAttributeMaskSurfaceTangent                \
  385.     (1 << (kQ3AttributeTypeSurfaceTangent - 1))
  386.  
  387. #define kQ3XAttributeMaskHighlightState                \
  388.     (1 << (kQ3AttributeTypeHighlightState - 1))
  389.  
  390. #define kQ3XAttributeMaskSurfaceShader                \
  391.     (1 << (kQ3AttributeTypeSurfaceShader - 1))
  392.  
  393. #define kQ3XAttributeMaskCustomAttribute            0x80000000
  394.  
  395. #define kQ3XAttributeMaskAll                        \
  396.     (                                                 \
  397.         kQ3XAttributeMaskSurfaceUV             |         \
  398.         kQ3XAttributeMaskShadingUV             |         \
  399.         kQ3XAttributeMaskNormal             |         \
  400.         kQ3XAttributeMaskAmbientCoefficient |         \
  401.         kQ3XAttributeMaskDiffuseColor         |         \
  402.         kQ3XAttributeMaskSpecularColor         |         \
  403.         kQ3XAttributeMaskSpecularControl     |         \
  404.         kQ3XAttributeMaskTransparencyColor     |         \
  405.         kQ3XAttributeMaskSurfaceTangent     |         \
  406.         kQ3XAttributeMaskHighlightState        |        \
  407.         kQ3XAttributeMaskSurfaceShader        |        \
  408.         kQ3XAttributeMaskCustomAttribute            \
  409.     )
  410.  
  411. #define kQ3XAttributeMaskInherited                    \
  412.     (                                                 \
  413.         kQ3XAttributeMaskSurfaceUV             |         \
  414.         kQ3XAttributeMaskShadingUV             |         \
  415.         kQ3XAttributeMaskNormal             |         \
  416.         kQ3XAttributeMaskAmbientCoefficient |        \
  417.         kQ3XAttributeMaskDiffuseColor         |         \
  418.         kQ3XAttributeMaskSpecularColor         |         \
  419.         kQ3XAttributeMaskSpecularControl     |         \
  420.         kQ3XAttributeMaskTransparencyColor     |         \
  421.         kQ3XAttributeMaskSurfaceTangent     |         \
  422.         kQ3XAttributeMaskHighlightState             \
  423.     )
  424.  
  425. #define kQ3XAttributeMaskInterpolated                \
  426.     (                                                 \
  427.         kQ3XAttributeMaskSurfaceUV             |         \
  428.         kQ3XAttributeMaskShadingUV             |         \
  429.         kQ3XAttributeMaskNormal             |         \
  430.         kQ3XAttributeMaskAmbientCoefficient |         \
  431.         kQ3XAttributeMaskDiffuseColor         |         \
  432.         kQ3XAttributeMaskSpecularColor         |         \
  433.         kQ3XAttributeMaskSpecularControl     |         \
  434.         kQ3XAttributeMaskTransparencyColor     |         \
  435.         kQ3XAttributeMaskSurfaceTangent     |         \
  436.     )
  437.  
  438. typedef unsigned long TQ3XAttributeMask;
  439.  
  440. QD3D_EXPORT TQ3XAttributeMask QD3D_CALL Q3XAttributeSet_GetMask(
  441.     TQ3AttributeSet            attributeSet);
  442.  
  443.  
  444. /******************************************************************************
  445.  **                                                                             **
  446.  **                            Renderer Draw Context Tools                         **
  447.  **                                                                             **
  448.  *****************************************************************************/
  449.  
  450. typedef struct TQ3XDrawRegionPrivate    *TQ3XDrawRegion;
  451.  
  452. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetDrawRegion(
  453.     TQ3DrawContextObject    drawContext,
  454.     TQ3XDrawRegion            *drawRegion);
  455.  
  456. typedef enum TQ3XDrawContextValidationMasks {
  457.     kQ3XDrawContextValidationClearFlags            =    0x00000000L,
  458.  
  459.     kQ3XDrawContextValidationDoubleBuffer        =    1 << 0,
  460.     kQ3XDrawContextValidationShader                =    1 << 1,
  461.     kQ3XDrawContextValidationClearFunction        =    1 << 2,
  462.     kQ3XDrawContextValidationActiveBuffer        =    1 << 3,
  463.     kQ3XDrawContextValidationInternalOffScreen    =    1 << 4,
  464.     kQ3XDrawContextValidationPane                =    1 << 5,
  465.     kQ3XDrawContextValidationMask                =    1 << 6,
  466.     kQ3XDrawContextValidationDevice                =    1 << 7,
  467.     kQ3XDrawContextValidationWindow                =    1 << 8,
  468.     kQ3XDrawContextValidationWindowSize            =    1 << 9,
  469.     kQ3XDrawContextValidationWindowClip            =    1 << 10,
  470.     kQ3XDrawContextValidationWindowPosition        =    1 << 11,
  471.     kQ3XDrawContextValidationPlatformAttributes    =    1 << 12,
  472.     kQ3XDrawContextValidationForegroundShader    =    1 << 13,
  473.     kQ3XDrawContextValidationBackgroundShader    =    1 << 14,
  474.     kQ3XDrawContextValidationColorPalette        =    1 << 15,
  475.     kQ3XDrawContextValidationAll                =    ~0
  476. } TQ3XDrawContextValidationMasks;
  477.  
  478. typedef unsigned long TQ3XDrawContextValidation;
  479.  
  480. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_ClearValidationFlags(
  481.     TQ3DrawContextObject        drawContext);
  482.  
  483. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawContext_GetValidationFlags(
  484.     TQ3DrawContextObject        drawContext,
  485.     TQ3XDrawContextValidation    *validationFlags);
  486.  
  487.  
  488. /******************************************************************************
  489.  **                                                                             **
  490.  **                            Renderer Draw Region Tools                         **
  491.  **                                                                             **
  492.  *****************************************************************************/
  493.  
  494. typedef enum TQ3XDevicePixelType {    /* These do not indicate byte ordering   */
  495.     kQ3XDevicePixelTypeInvalid        = 0, /* Unknown, un-initialized type     */
  496.     kQ3XDevicePixelTypeRGB32        = 1, /* Alpha:8 (ignored), R:8, G:8, B:8 */
  497.     kQ3XDevicePixelTypeARGB32        = 2, /* Alpha:8, R:8, G:8, B:8              */
  498.     kQ3XDevicePixelTypeRGB24        = 3, /* 24 bits/pixel, R:8, G:8, B:8     */
  499.     kQ3XDevicePixelTypeRGB16        = 4, /* Alpha:1 (ignored), R:5, G:5, B:5 */
  500.     kQ3XDevicePixelTypeARGB16        = 5, /* Alpha:1, R:5, G:5, B:5              */
  501.     kQ3XDevicePixelTypeRGB16_565    = 6, /* 16 bits/pixel, R:5, G:6, B:5     */
  502.     kQ3XDevicePixelTypeIndexed8        = 7, /* 8-bit color table index             */
  503.     kQ3XDevicePixelTypeIndexed4        = 8, /* 4-bit color table index             */
  504.     kQ3XDevicePixelTypeIndexed2        = 9, /* 2-bit color table index             */
  505.     kQ3XDevicePixelTypeIndexed1        = 10 /* 1-bit color table index             */
  506. } TQ3XDevicePixelType;
  507.  
  508. typedef enum TQ3XClipMaskState {
  509.     kQ3XClipMaskFullyExposed,
  510.     kQ3XClipMaskPartiallyExposed,
  511.     kQ3XClipMaskNotExposed
  512. } TQ3XClipMaskState;
  513.  
  514. typedef struct TQ3XColorDescriptor {
  515.     unsigned long            redShift;
  516.     unsigned long            redMask;
  517.     unsigned long            greenShift;
  518.     unsigned long            greenMask;
  519.     unsigned long            blueShift;
  520.     unsigned long            blueMask;
  521.     unsigned long            alphaShift;
  522.     unsigned long            alphaMask;
  523. } TQ3XColorDescriptor;
  524.  
  525. typedef struct TQ3XDrawRegionDescriptor {
  526.     unsigned long            width;
  527.     unsigned long            height;
  528.     unsigned long            rowBytes;
  529.     unsigned long            pixelSize;
  530.     TQ3XDevicePixelType        pixelType;
  531.     TQ3XColorDescriptor        colorDescriptor;
  532.     TQ3Endian                bitOrder;
  533.     TQ3Endian                byteOrder;
  534.     TQ3Bitmap                *clipMask;
  535. } TQ3XDrawRegionDescriptor;
  536.  
  537. typedef enum TQ3XDrawRegionServicesMasks {
  538.     kQ3XDrawRegionServicesNoneFlag                =    0L,
  539.     kQ3XDrawRegionServicesClearFlag                =    1 << 0,
  540.     kQ3XDrawRegionServicesDontLockDDSurfaceFlag    =    1 << 1
  541. } TQ3XDrawRegionServicesMasks;
  542.  
  543. typedef unsigned long TQ3XDrawRegionServices;
  544.  
  545. typedef void (QD3D_CALLBACK *TQ3XDrawRegionRendererPrivateDeleteMethod)(
  546.     void    *rendererPrivate);
  547.  
  548. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceScaleX( 
  549.     TQ3XDrawRegion     drawRegion,
  550.     float            *deviceScaleX);
  551.  
  552. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceScaleY( 
  553.     TQ3XDrawRegion     drawRegion,
  554.     float            *deviceScaleY);
  555.  
  556.  
  557. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceOffsetX( 
  558.     TQ3XDrawRegion     drawRegion,
  559.     float            *deviceOffsetX);
  560.  
  561. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceOffsetY( 
  562.     TQ3XDrawRegion     drawRegion,
  563.     float            *deviceOffsetX);
  564.  
  565.  
  566. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowScaleX( 
  567.     TQ3XDrawRegion     drawRegion,
  568.     float            *windowScaleX);
  569.  
  570. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowScaleY( 
  571.     TQ3XDrawRegion     drawRegion,
  572.     float            *windowScaleY);
  573.  
  574.  
  575. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowOffsetX( 
  576.     TQ3XDrawRegion     drawRegion,
  577.     float            *windowOffsetX);
  578.  
  579. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetWindowOffsetY( 
  580.     TQ3XDrawRegion     drawRegion,
  581.     float            *windowOffsetY);
  582.  
  583. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_IsActive( 
  584.     TQ3XDrawRegion     drawRegion,
  585.     TQ3Boolean        *isActive);
  586.  
  587.  
  588. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetNextRegion( 
  589.     TQ3XDrawRegion     drawRegion,
  590.     TQ3XDrawRegion    *nextDrawRegion);
  591.  
  592. /* 
  593.  *  One of the next two functions must be called before using a draw region 
  594.  */
  595.  
  596. /*
  597.  *    Use this Start function if double buffering/image access services from the
  598.  *    Draw Context are not needed, you may still request clear for example
  599.  */
  600. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_Start( 
  601.     TQ3XDrawRegion                drawRegion, 
  602.     TQ3XDrawRegionServices        services,
  603.     TQ3XDrawRegionDescriptor    **descriptor);
  604.  
  605. /*
  606.  *    Use this Start function if double buffering or image access services from 
  607.  *  the Draw Context are needed.
  608.  */
  609. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_StartAccessToImageBuffer( 
  610.     TQ3XDrawRegion                drawRegion, 
  611.     TQ3XDrawRegionServices        services,
  612.     TQ3XDrawRegionDescriptor    **descriptor,
  613.     void                        **image);
  614.  
  615. /*
  616.  *    This function is used to indicate that access to a DrawRegion is ended.
  617.  */
  618. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_End( 
  619.     TQ3XDrawRegion         drawRegion);
  620.  
  621. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetDeviceTransform( 
  622.     TQ3XDrawRegion         drawRegion,
  623.     TQ3Matrix4x4        **deviceTransform);
  624.  
  625. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetClipFlags( 
  626.     TQ3XDrawRegion         drawRegion,
  627.     TQ3XClipMaskState    *clipMaskState);
  628.     
  629. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetClipMask( 
  630.     TQ3XDrawRegion         drawRegion,
  631.     TQ3Bitmap            **clipMask);
  632.     
  633. #if defined(WINDOW_SYSTEM_MACINTOSH) && WINDOW_SYSTEM_MACINTOSH
  634.  
  635. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetClipRegion(
  636.     TQ3XDrawRegion    drawRegion,
  637.     RgnHandle        *rgnHandle);
  638.     
  639. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetGDHandle(
  640.     TQ3XDrawRegion    drawRegion,
  641.     GDHandle        *gdHandle);
  642.     
  643. #endif  /* WINDOW_SYSTEM_MACINTOSH  */     
  644.  
  645. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetRendererPrivate( 
  646.     TQ3XDrawRegion     drawRegion,
  647.     void            **rendererPrivate);
  648.  
  649. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_SetRendererPrivate( 
  650.     TQ3XDrawRegion                                 drawRegion, 
  651.     const void                                     *rendererPrivate,
  652.     TQ3XDrawRegionRendererPrivateDeleteMethod    deleteMethod);
  653.  
  654. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_SetUseDefaultRendererFlag( 
  655.     TQ3XDrawRegion    drawRegion, 
  656.     TQ3Boolean         flag);
  657.  
  658. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_GetUseDefaultRendererFlag( 
  659.     TQ3XDrawRegion    drawRegion,
  660.     TQ3Boolean        *useDefaultRenderingFlag);
  661.  
  662. #if defined(ESCHER_VER_FUTURE) && ESCHER_VER_FUTURE
  663.     
  664. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_LookupColor(
  665.     TQ3XDrawRegion    drawRegion,
  666.     float            red,
  667.     float            green,
  668.     float            blue,
  669.     float            alpha,
  670.     unsigned long    *pixelValue);
  671.  
  672. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_PutPixel(
  673.     TQ3XDrawRegion    drawRegion,
  674.     unsigned long    x,
  675.     unsigned long    y,
  676.     float            red,
  677.     float            green,
  678.     float            blue,
  679.     float            alpha);
  680.     
  681. QD3D_EXPORT TQ3Status QD3D_CALL Q3XDrawRegion_PutRaster(
  682.     TQ3XDrawRegion        drawRegion,
  683.     unsigned long        x,
  684.     unsigned long        y,
  685.     unsigned long        width,
  686.     unsigned long        height,
  687.     const TQ3ColorARGB    *raster);
  688.     
  689. #endif  /*  ESCHER_VER_FUTURE  */
  690.  
  691.  
  692. /******************************************************************************
  693.  **                                                                             **
  694.  **                            Renderer Class Methods                             **
  695.  **                                                                             **
  696.  *****************************************************************************/
  697. /*
  698.  *    Methods from Object
  699.  *        kQ3XMethodTypeObjectClassRegister
  700.  *        kQ3XMethodTypeObjectClassUnregister
  701.  *        kQ3XMethodTypeObjectNew
  702.  *        kQ3XMethodTypeObjectDelete
  703.  *        kQ3XMethodTypeObjectRead
  704.  *        kQ3XMethodTypeObjectTraverse
  705.  *        kQ3XMethodTypeObjectWrite
  706.  *        
  707.  *    Methods from Shared
  708.  *        kQ3MethodTypeSharedEdited
  709.  *
  710.  *    Renderer Methods
  711.  *    
  712.  *    The renderer methods should be implemented according to the type
  713.  *    of renderer being written.
  714.  *
  715.  *    For the purposes of documentation, there are two basic types of
  716.  *    renderers: 
  717.  *
  718.  *        Interactive
  719.  *            Interactive Renderer
  720.  *            WireFrame Renderer
  721.  *        
  722.  *        Deferred
  723.  *            a ray-tracer
  724.  *            painter's algorithm renderer (cached in a BSP triangle tree)
  725.  *            an artistic renderer (simulates a pencil drawing, etc.)
  726.  *
  727.  *    The main difference is how each renderer handles incoming state and 
  728.  *    geometry.
  729.  *
  730.  *    An interactive renderer immediately transforms, culls, and shades
  731.  *    incoming geometry and performs rasterization. For example, in a 
  732.  *    single-buffered WireFrame renderer, you will see a new triangle
  733.  *    immediately after Q3Triangle_Draw (if it's visible, of course).
  734.  *
  735.  *    A deferred renderer caches the view state and each geometry, 
  736.  *    converting into any internal queue of drawing commands. Rasterization
  737.  *    is not actually performed until all data has been submitted.
  738.  *    
  739.  *    For example, a ray-tracer may not rasterize anything until the
  740.  *    end of the rendering loop, or until an EndFrame call is made.
  741.  */
  742.  
  743.     
  744. /******************************************************************************
  745.  **                                                                             **
  746.  **                        Renderer User Interface Methods                         **
  747.  **                                                                             **
  748.  *****************************************************************************/
  749.  
  750. /*
  751.  *    TQ3XRendererModalConfigureMethod
  752.  *    
  753.  *    This method should pop up a modal dialog to edit the renderer settings 
  754.  *    found in the renderer private. 
  755.  *    
  756.  *    dialogAnchor - is platform specific data passed by the client to support
  757.  *      movable modal dialogs. 
  758.  *    MacOS: this is a callback to the calling application's event handler.
  759.  *      The renderer calls this function with events not handled by the 
  760.  *      settings dialog. This is necessary in order to support movable modal 
  761.  *      dialogs. An application's event handler must return kQ3True if it 
  762.  *      handles the event passed to the callback or kQ3False if not. 
  763.  *      An application which doesn't want to support a movable modal configure
  764.  *      dialog should pass NULL for the clientEventHandler of TQ3DialogAnchor.
  765.  *      A renderer should implement a non-movable style dialog in that case.
  766.  *    Win32: this is the HWND of the owning window (typically an application's
  767.  *      main window).  (Win32 application modal dialogs are always movable.)
  768.  *  canceled - returns a boolean inditacating that the user canceled the 
  769.  *    dialog.
  770.  *    
  771.  *    OPTIONAL
  772.  */
  773. #define kQ3XMethodTypeRendererModalConfigure \
  774.     Q3_METHOD_TYPE('r','d','m','c')    
  775. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererModalConfigureMethod)(
  776.     TQ3RendererObject            renderer,
  777.     TQ3DialogAnchor             dialogAnchor, 
  778.     TQ3Boolean                    *canceled,    
  779.     void                        *rendererPrivate);
  780.  
  781. /*
  782.  *    kQ3XMethodTypeRendererGetConfigurationData
  783.  *    
  784.  *        Allows an application to collect private configuration data from the
  785.  *      renderer which it will then save. For example in a preference file, 
  786.  *      a registry key (on Windows) or in a style template. An application 
  787.  *      should tag this data with the renderer's object name.
  788.  *    
  789.  *        If dataBuffer is NULL actualDataSize returns the required size in 
  790.  *        bytes of a data buffer large enough to store private data. 
  791.  *
  792.  *      bufferSize is the actual size of the memory block pointed to by 
  793.  *        dataBuffer
  794.  *
  795.  *        actualDataSize - on return the actual number of bytes written to the
  796.  *        buffer or if dataBuffer is NULL the required size of dataBuffer
  797.  *
  798.  *    OPTIONAL
  799.  */
  800. #define kQ3XMethodTypeRendererGetConfigurationData \
  801.     Q3_METHOD_TYPE('r','d','g','p')    
  802. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererGetConfigurationDataMethod)(
  803.     TQ3RendererObject            renderer, 
  804.     unsigned char                *dataBuffer, 
  805.     unsigned long                bufferSize,
  806.     unsigned long                *actualDataSize,    
  807.     void                        *rendererPrivate);
  808.  
  809. /*
  810.  *    TQ3XRendererSetConfigurationDataMethod
  811.  *    
  812.  *        Allows an application to pass private configuration data which has
  813.  *         previously  been obtained from a renderer via 
  814.  *        Q3Renderer_GetConfigurationData. For example in a preference file or 
  815.  *        in a style template. An application should tag this data with the 
  816.  *        renderer's object name.
  817.  *    
  818.  *      bufferSize is the actual size of the memory block pointed to by 
  819.  *        dataBuffer
  820.  *
  821.  *    OPTIONAL
  822.  */
  823. #define kQ3XMethodTypeRendererSetConfigurationData \
  824.     Q3_METHOD_TYPE('r','d','s','p')    
  825. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSetConfigurationDataMethod)(
  826.     TQ3RendererObject            renderer, 
  827.     unsigned char                *dataBuffer, 
  828.     unsigned long                bufferSize,    
  829.     void                        *rendererPrivate);
  830.  
  831. /******************************************************************************
  832.  **                                                                             **
  833.  **                        Renderer Drawing State Methods                         **
  834.  **                                                                             **
  835.  *****************************************************************************/
  836. /*
  837.  *    TQ3RendererStartFrame
  838.  *    
  839.  *    The StartFrame method is called first at Q3View_StartRendering
  840.  *    and should:
  841.  *        - initialize any renderer state to defaults
  842.  *        - extract any and all useful data from the drawContext
  843.  *
  844.  *    If your renderer passed in kQ3RendererFlagClearBuffer at 
  845.  *    registration, then it should also:
  846.  *        - clear the drawContext 
  847.  *    
  848.  *        When clearing, your renderer may opt to:
  849.  *        - NOT clear anything (if you touch every pixel, for example)
  850.  *        - to clear with your own routine, or
  851.  *        - to use the draw context default clear method by calling 
  852.  *        Q3DrawContext_Clear. Q3DrawContext_Clear takes advantage of
  853.  *        any available hardware in the system for clearing.
  854.  *    
  855.  *    This call also signals the start of all default submit commands from
  856.  *    the view. The renderer will receive updates for the default view
  857.  *    state via its Update methods before StartPass is called.
  858.  *    
  859.  *    REQUIRED
  860.  */
  861. #define kQ3XMethodTypeRendererStartFrame    \
  862.     Q3_METHOD_TYPE('r','d','c','l')
  863. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererStartFrameMethod)(
  864.     TQ3ViewObject            view,
  865.     void                    *rendererPrivate,
  866.     TQ3DrawContextObject    drawContext);
  867.     
  868. /*
  869.  *    kQ3XMethodTypeRendererStartPass
  870.  *    TQ3XRendererStartPassMethod
  871.  *    
  872.  *    The StartPass method is called during Q3View_StartRendering but after
  873.  *    the StartFrame command. It should:
  874.  *        - collect camera and light information
  875.  *    
  876.  *    If your renderer supports deferred camera transformation, camera is the
  877.  *    main camera which will be submitted in the hierarchy somewhere. It
  878.  *    is never NULL.
  879.  *
  880.  *    If your renderer does not support deferred camera transformation, camera
  881.  *    is the transformed camera.
  882.  *
  883.  *    If your renderer supports deferred light transformation, lights will be
  884.  *    NULL, and will be submitted to your light draw methods instead.
  885.  *
  886.  *    This call signals the end of the default update state, and the start of 
  887.  *  submit commands from the user to the view.
  888.  *
  889.  *    REQUIRED
  890.  */
  891. #define kQ3XMethodTypeRendererStartPass \
  892.     Q3_METHOD_TYPE('r','d','s','t')
  893. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererStartPassMethod)(
  894.     TQ3ViewObject            view,
  895.     void                    *rendererPrivate,
  896.     TQ3CameraObject            camera,
  897.     TQ3GroupObject            lightGroup);
  898.  
  899. /*
  900.  *    kQ3XMethodTypeRendererFlushFrame
  901.  *    TQ3XRendererFlushFrameMethod
  902.  *    
  903.  *    This call is only implemented by asynchronous renderers.
  904.  *    
  905.  *    The FlushFrame method is called between the StartPass and EndPass
  906.  *    methods and is called when the user wishes to flush any asynchronous
  907.  *    drawing tasks (which draw to the drawcontext), but does not want 
  908.  *    to block.
  909.  *    
  910.  *    The result of this call is that an image should "eventually" appear
  911.  *    asynchronously.
  912.  *    
  913.  *    For asynchronous rendering, this call is non-blocking.
  914.  *    
  915.  *    An interactive renderer should ensure that all received
  916.  *    geometries are drawn in the image.
  917.  *    
  918.  *    An interactive renderer that talks to hardware should force
  919.  *    the hardware to generate an image.
  920.  *    
  921.  *    A deferred renderer should exhibit a similar behaviour,
  922.  *    though it is not required.  A deferred renderer should spawn
  923.  *    a process that generates a partial image from the currently
  924.  *    accumulated drawing state. 
  925.  *    
  926.  *    However, for renderers such as ray-tracers which generally are
  927.  *    quite compute-intensive, FlushFrame is not required and is a no-op.
  928.  *
  929.  *    OPTIONAL
  930.  */
  931. #define kQ3XMethodTypeRendererFlushFrame    \
  932.     Q3_METHOD_TYPE('r','d','f','l')
  933. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererFlushFrameMethod)(
  934.     TQ3ViewObject            view,
  935.     void                    *rendererPrivate,
  936.     TQ3DrawContextObject    drawContext);
  937.  
  938. /*
  939.  *    kQ3XMethodTypeRendererEndPass
  940.  *    TQ3XRendererEndPassMethod
  941.  *    
  942.  *    The EndPass method is called at Q3View_EndRendering and signals
  943.  *    the end of submit commands to the view.
  944.  *
  945.  *    If an error occurs, the renderer should call Q3XError_Post and
  946.  *    return kQ3ViewStatusError.
  947.  *    
  948.  *    If a renderer requires another pass on the renderering data,
  949.  *    it should return kQ3ViewStatusRetraverse.
  950.  *    
  951.  *    If rendering was cancelled, this function will not be called
  952.  *    and the view will handle returning kQ3ViewStatusCancelled;
  953.  *    
  954.  *    Otherwise, your renderer should begin completing the process of 
  955.  *    generating the image in the drawcontext. If you have buffered
  956.  *    any drawing data, flush it. RendererEnd should have a similar
  957.  *    effect as RendererFlushFrame.
  958.  *    
  959.  *    If the renderer is synchronous:
  960.  *        - complete rendering of the entire frame
  961.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer
  962.  *            - Update the front buffer
  963.  *        else
  964.  *            - DrawContext will update the front buffer after returning
  965.  *
  966.  *    If the renderer is asynchronous
  967.  *        - spawn rendering thread for entire frame
  968.  *        if the renderer supports kQ3RendererClassSupportDoubleBuffer,
  969.  *            - you must eventually update the front buffer asynchronously
  970.  *        else
  971.  *            - you must eventually update the back buffer asynchronously
  972.  *            
  973.  *    REQUIRED
  974.  */
  975. #define kQ3XMethodTypeRendererEndPass    \
  976.     Q3_METHOD_TYPE('r','d','e','d')
  977. typedef TQ3ViewStatus (QD3D_CALLBACK *TQ3XRendererEndPassMethod)(
  978.     TQ3ViewObject            view,
  979.     void                    *rendererPrivate);
  980.  
  981. /*
  982.  *    kQ3XMethodTypeRendererEndFrame
  983.  *    TQ3XRendererEndFrame
  984.  *    
  985.  *    This call is only implemented by asynchronous renderers.
  986.  *
  987.  *    The EndFrame method is called from Q3View_Sync, which is
  988.  *    called after Q3View_EndRendering and signals that the user
  989.  *    wishes to see the completed image and is willing to block.
  990.  *    
  991.  *    If your renderer supports kQ3RendererFlagDoubleBuffer
  992.  *        - update the front buffer completely 
  993.  *    else
  994.  *        - update the back buffer completely
  995.  *
  996.  *    This call is equivalent in functionality to RendererFlushFrame
  997.  *    but blocks until the image is completed.
  998.  *    
  999.  *    If no method is supplied, the default is a no-op.
  1000.  *    
  1001.  *    NOTE: Registering a method of this type indicates that your renderer will
  1002.  *    be rendering after Q3View_EndRendering has been called.
  1003.  *    
  1004.  *    OPTIONAL
  1005.  */
  1006. #define kQ3XMethodTypeRendererEndFrame    \
  1007.     Q3_METHOD_TYPE('r','d','s','y')
  1008. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererEndFrameMethod)(
  1009.     TQ3ViewObject            view,
  1010.     void                    *rendererPrivate,
  1011.     TQ3DrawContextObject    drawContext);
  1012.     
  1013. /*
  1014.  *    The RendererCancel method is called after Q3View_StartRendering
  1015.  *    and signals the termination of all rendering operations.
  1016.  *
  1017.  *    A renderer should clean up any cached data, and cancel all 
  1018.  *    rendering operations.
  1019.  *    
  1020.  *    If called before Q3View_EndRendering, the RendererEnd method
  1021.  *    is NOT called.
  1022.  *    
  1023.  *    If called after Q3View_EndRendering, the renderer should kill
  1024.  *    any threads and terminate any further rendering.
  1025.  *    
  1026.  *    REQUIRED
  1027.  */
  1028. #define kQ3XMethodTypeRendererCancel    \
  1029.     Q3_METHOD_TYPE('r','d','a','b')
  1030. typedef void (QD3D_CALLBACK *TQ3XRendererCancelMethod)(
  1031.     TQ3ViewObject            view,
  1032.     void                    *rendererPrivate);
  1033.  
  1034.  
  1035. /******************************************************************************
  1036.  **                                                                             **
  1037.  **                        Renderer DrawContext Methods                         **
  1038.  **                                                                             **
  1039.  *****************************************************************************/
  1040.  
  1041. /*
  1042.  *    kQ3XMethodTypeRendererPush
  1043.  *    TQ3XRendererPushMethod
  1044.  *    
  1045.  *    kQ3XMethodTypeRendererPop
  1046.  *    TQ3XRendererPopMethod
  1047.  *    
  1048.  *    These methods are called whenever the graphics state in the view
  1049.  *    is pushed or popped. The user may isolate state by calling:
  1050.  *    
  1051.  *    Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &red, view);
  1052.  *    Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &blue, view);
  1053.  *    Q3Attribute_Submit(kQ3AttributeTypeSpecularColor, &white, view);
  1054.  *    Q3Box_Submit(&unitBox, view);
  1055.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1056.  *    Q3Push_Submit(view);
  1057.  *        Q3Attribute_Submit(kQ3AttributeTypeDiffuseColor, &blue, view);
  1058.  *        Q3Attribute_Submit(kQ3AttributeTypeTransparencyColor, &green, view);
  1059.  *        Q3Box_Submit(&unitBox, view);
  1060.  *    Q3Pop_Submit(view);    
  1061.  *    Q3TranslateTransform_Submit(&unitVector, view);
  1062.  *    Q3Box_Submit(&unitBox, view);
  1063.  *    
  1064.  *    or by submitting a display group which pushes and pops.
  1065.  *    
  1066.  *    If you support RendererPush and RendererPop in your renderer:
  1067.  *        - you must maintain your drawing state as a stack, as well.
  1068.  *        - you will not be updated with the popped state after
  1069.  *            RendererPop is called.
  1070.  *
  1071.  *    If you do not support Push and Pop in your renderer:
  1072.  *        - you may maintain a single copy of the drawing state.
  1073.  *        - you will be updated with changed fields after the view stack is
  1074.  *            popped.
  1075.  *
  1076.  *    A renderer that supports Push and Pop gets called in the following
  1077.  *    sequence (from example above):
  1078.  *    
  1079.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1080.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1081.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1082.  *    RendererUpdateMatrixLocalToWorld(...)
  1083.  *    RendererSubmitGeometryBox(...)
  1084.  *    RendererPush(...)
  1085.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1086.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1087.  *        RendererSubmitGeometryBox(...)
  1088.  *    RendererPop(...)
  1089.  *    RendererUpdateMatrixLocalToWorld(...)
  1090.  *    RendererSubmitGeometryBox(...)
  1091.  *
  1092.  *    A renderer that does not supports Push and Pop gets called in the
  1093.  *    following sequence:
  1094.  *    
  1095.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1096.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1097.  *    RendererUpdateAttributeSpecularColor(&white,...)
  1098.  *    RendererUpdateMatrixLocalToWorld(...)
  1099.  *    RendererSubmitGeometryBox(...)
  1100.  *        RendererUpdateAttributeDiffuseColor(&blue,...)
  1101.  *        RendererUpdateAttributeTransparencyColor(&green,...)
  1102.  *        RendererSubmitGeometryBox(...)
  1103.  *    RendererUpdateAttributeDiffuseColor(&red,...)
  1104.  *    RendererUpdateAttributeTransparencyColor(&blue,...)
  1105.  *    RendererUpdateMatrixLocalToWorld(...)
  1106.  *    RendererSubmitGeometryBox(...)
  1107.  *    
  1108.  */
  1109. #define kQ3XMethodTypeRendererPush    \
  1110.     Q3_METHOD_TYPE('r','d','p','s')
  1111. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererPushMethod)(
  1112.     TQ3ViewObject            view,
  1113.     void                    *rendererPrivate);
  1114.  
  1115. #define kQ3XMethodTypeRendererPop    \
  1116.     Q3_METHOD_TYPE('r','d','p','o')
  1117. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererPopMethod)(
  1118.     TQ3ViewObject            view,
  1119.     void                    *rendererPrivate);
  1120.  
  1121.  
  1122. /******************************************************************************
  1123.  **                                                                             **
  1124.  **                            Renderer Cull Methods                             **
  1125.  **                                                                             **
  1126.  *****************************************************************************/
  1127. /*
  1128.  *    kQ3XMethodTypeRendererIsBoundingBoxVisible
  1129.  *    TQ3XRendererIsBoundingBoxVisibleMethod
  1130.  *    
  1131.  *    This method is called to cull complex groups and geometries 
  1132.  *    given their bounding box in local space.
  1133.  *    
  1134.  *    It should transform the local-space bounding box coordinates to
  1135.  *    frustum space and return a TQ3Boolean return value indicating
  1136.  *    whether the box appears within the viewing frustum.
  1137.  *    
  1138.  *    If no method is supplied, the default behvaiour is to return
  1139.  *    kQ3True.
  1140.  *    
  1141.  *    TODO: Default to cull to { (-1,1), (-1,1), (0,1) } frustum?
  1142.  */
  1143. #define kQ3XMethodTypeRendererIsBoundingBoxVisible    \
  1144.     Q3_METHOD_TYPE('r','d','b','x')
  1145. typedef TQ3Boolean (QD3D_CALLBACK *TQ3XRendererIsBoundingBoxVisibleMethod)(
  1146.     TQ3ViewObject            view,
  1147.     void                    *rendererPrivate,
  1148.     const TQ3BoundingBox    *bBox);
  1149.  
  1150. #if defined(ESCHER_VER_FUTURE) && ESCHER_VER_FUTURE
  1151.  
  1152. /******************************************************************************
  1153.  **                                                                             **
  1154.  **                            Renderer Cache Methods                             **
  1155.  **                                                                             **
  1156.  *****************************************************************************/
  1157.  
  1158. /*
  1159.  *    kQ3XMethodTypeRendererStartCache
  1160.  *    TQ3XRendererStartCacheMethod
  1161.  *    
  1162.  *    The start cache method is called at Q3View_StartRendererCache and
  1163.  *    signals that the application wishes to bracket some information
  1164.  *    that is static within a scene.
  1165.  *    
  1166.  *    If rendererCache is NULL, then the renderer should prepare to cache
  1167.  *    all information until the EndCache method is called.
  1168.  *    
  1169.  *    If rendererCache is non-NULL, then the renderer should validate the
  1170.  *    pre-existing cache.
  1171.  *    
  1172.  *    If the cache is invalid, the call should return kQ3True (meaning
  1173.  *    please retraverse the data) and delete the cache. The renderer
  1174.  *    should prepare to cache all submitted information until the EndCache
  1175.  *    method is called.
  1176.  *    
  1177.  *    If the cache is valid, the renderer should apply the cache to its
  1178.  *    state and/or the image, and return kQ3False (don't retraverse the
  1179.  *    data). EndCache will not be called.
  1180.  *    
  1181.  *    If no method is supplied, the default is to return kQ3True.
  1182.  *    
  1183.  *    OPTIONAL
  1184.  */
  1185. #define kQ3XMethodTypeRendererStartCache    \
  1186.     Q3_METHOD_TYPE('r','d','b','c')
  1187. typedef TQ3Boolean (QD3D_CALLBACK *TQ3XRendererStartCacheMethod)(
  1188.     TQ3ViewObject            view,
  1189.     void                    *rendererPrivate,
  1190.     void                    *rendererCache);
  1191.  
  1192. /*
  1193.  *    kQ3XMethodTypeRendererEndCache
  1194.  *    TQ3XRendererEndCacheMethod
  1195.  *    
  1196.  *    The end cache method is called at Q3View_EndRenderingCache and
  1197.  *    indicates that all cached information has been submitted. It
  1198.  *    returns a pointer to a private data structure containing the
  1199.  *    cached data. EndCache will only be called after StartCache.
  1200.  *
  1201.  *    If NULL is returned, it indicates that the renderer can not
  1202.  *    cache the information.
  1203.  *    
  1204.  *    If no method is supplied, the default is to return NULL.
  1205.  *    
  1206.  *    OPTIONAL
  1207.  */
  1208. #define kQ3XMethodTypeRendererEndCache    \
  1209.     Q3_METHOD_TYPE('r','d','e','c')
  1210. typedef void *(QD3D_CALLBACK *TQ3XRendererEndCacheMethod)(
  1211.     TQ3ViewObject            view,
  1212.     void                    *rendererPrivate);
  1213.  
  1214. /*
  1215.  *    kQ3XMethodTypeRendererDeleteCache
  1216.  *    TQ3XRendererDeleteCacheMethod
  1217.  *    
  1218.  *    The delete cache method is called on a cache that has been 
  1219.  *    invalidated.
  1220.  *    
  1221.  *    NOTE: When the RendererStartCache method is passed a cache to 
  1222.  *    validate and it returns kQ3True (cache is invalid, please
  1223.  *    retraverse data), this method is NOT called on the invalid cache.
  1224.  *    It is up to the renderer to delete or re-use the cache passed in.
  1225.  *    
  1226.  *    If no method is supplied, caches are assumed to be unsupported, or
  1227.  *    freed by the renderer.
  1228.  *    
  1229.  *    OPTIONAL
  1230.  */
  1231. #define kQ3XMethodTypeRendererDeleteCache \
  1232.     Q3_METHOD_TYPE('r','d','d','c')
  1233. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererDeleteCacheMethod)(
  1234.     TQ3RendererObject        renderer,
  1235.     void                    *rendererPrivate,
  1236.     void                    *rendererCache);
  1237.  
  1238. #endif /* ESCHER_VER_FUTURE */
  1239.  
  1240. /******************************************************************************
  1241.  **                                                                             **
  1242.  **                        Renderer Object Support Methods                         **
  1243.  **                                                                             **
  1244.  *****************************************************************************/
  1245.  
  1246. /*
  1247.  *    Drawing methods (Geometry, Camera, Lights)
  1248.  *
  1249.  */
  1250.  
  1251. /*
  1252.  *    Geometry MetaHandler
  1253.  *    
  1254.  *    This metaHandler is required to support 
  1255.  *    
  1256.  *    kQ3GeometryTypeTriangle
  1257.  *    kQ3GeometryTypeLine
  1258.  *    kQ3GeometryTypePoint
  1259.  *    kQ3GeometryTypeMarker
  1260.  *    kQ3GeometryTypePixmapMarker
  1261.  *    
  1262.  *    REQUIRED
  1263.  */
  1264. #define kQ3XMethodTypeRendererSubmitGeometryMetaHandler    \
  1265.     Q3_METHOD_TYPE('r','d','g','m')
  1266. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererSubmitGeometryMetaHandlerMethod)(
  1267.     TQ3ObjectType                    geometryType);
  1268. /*
  1269.  *    The TQ3XRendererSubmitGeometryMetaHandlerMethod switches on geometryType
  1270.  *    of kQ3GeometryTypeFoo and returns methods of type:
  1271.  */
  1272. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSubmitGeometryMethod)(
  1273.     TQ3ViewObject                    view,
  1274.     void                            *rendererPrivate,
  1275.     TQ3GeometryObject                geometry,
  1276.     const void                        *publicData);
  1277.  
  1278.  
  1279. /*
  1280.  *    Camera MetaHandler
  1281.  *    
  1282.  *    This metaHandler, if supplied, indicates that your renderer
  1283.  *    handles deferred transformation of the main camera within a scene.
  1284.  *    
  1285.  *    If not supplied, or an unsupported camera is used, the view will do
  1286.  *    the transformation for the renderer and pass in a camera in the 
  1287.  *    StartPass method.
  1288.  *    
  1289.  *    OPTIONAL
  1290.  */
  1291. #define kQ3XMethodTypeRendererSubmitCameraMetaHandler    \
  1292.     Q3_METHOD_TYPE('r','d','c','m')
  1293. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererSubmitCameraMetaHandlerMethod)(
  1294.     TQ3ObjectType                    cameraType);
  1295. /*
  1296.  *    The TQ3XRendererSubmitCameraMetaHandlerMethod switches on cameraType
  1297.  *    of kQ3CameraTypeFoo and returns methods of type:
  1298.  */
  1299. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSubmitCameraMethod)(
  1300.     TQ3ViewObject                    view,
  1301.     void                            *rendererPrivate,
  1302.     TQ3CameraObject                    camera,
  1303.     const void                        *publicData);
  1304.  
  1305.  
  1306. /*
  1307.  *    Light MetaHandler
  1308.  *    
  1309.  *    This metaHandler, if supplied, indicates that your renderer
  1310.  *    handles deferred transformation of lights within a scene.
  1311.  *    
  1312.  *    If an unsupported light is encountered, it is ignored.
  1313.  *
  1314.  *    OPTIONAL
  1315.  */
  1316. #define kQ3XMethodTypeRendererSubmitLightMetaHandler    \
  1317.     Q3_METHOD_TYPE('r','d','l','g')
  1318. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererSubmitLightMetaHandlerMethod)(
  1319.     TQ3ObjectType                    lightType);
  1320. /*
  1321.  *    The TQ3XRendererSubmitLightMetaHandlerMethod switches on lightType
  1322.  *    of kQ3LightTypeFoo and returns methods of type:
  1323.  */
  1324. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererSubmitLightMethod)(
  1325.     TQ3ViewObject                    view,
  1326.     void                            *rendererPrivate,
  1327.     TQ3LightObject                    light,
  1328.     const void                        *publicData);
  1329.  
  1330. /*
  1331.  *
  1332.  *    Update methods
  1333.  *
  1334.  *    They are called whenever the state has changed. If the renderer supports
  1335.  *    the RendererPush and RendererPop methods, it must maintain its own state
  1336.  *    stack. Updates are not called for changed data when the view stack is
  1337.  *    popped.
  1338.  *
  1339.  *    See the comments for the RendererPush and RendererPop methods above
  1340.  *    for an example of how data is updated.
  1341.  *
  1342.  */
  1343.  
  1344. /*
  1345.  *    Style
  1346.  */
  1347. #define kQ3XMethodTypeRendererUpdateStyleMetaHandler        \
  1348.     Q3_METHOD_TYPE('r','d','y','u')
  1349. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererUpdateStyleMetaHandlerMethod)(
  1350.     TQ3ObjectType                    styleType);
  1351. /*
  1352.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on styleType
  1353.  *    of kQ3StyleTypeFoo and returns methods of type:
  1354.  */
  1355. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateStyleMethod)(
  1356.     TQ3ViewObject                    view,
  1357.     void                            *rendererPrivate,
  1358.     const void                        *publicData);
  1359.  
  1360. /*
  1361.  *    Attributes
  1362.  */
  1363. #define kQ3XMethodTypeRendererUpdateAttributeMetaHandler    \
  1364.     Q3_METHOD_TYPE('r','d','a','u')
  1365. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererUpdateAttributeMetaHandlerMethod)(
  1366.     TQ3AttributeType                attributeType);
  1367. /*
  1368.  *    The TQ3XRendererUpdateStyleMetaHandlerMethod switches on attributeType
  1369.  *    of kQ3AttributeTypeFoo and returns methods of type:
  1370.  */
  1371. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateAttributeMethod)(
  1372.     TQ3ViewObject                    view,
  1373.     void                            *rendererPrivate,
  1374.     const void                        *publicData);
  1375.  
  1376. /*
  1377.  *    Shaders
  1378.  */
  1379. #define kQ3XMethodTypeRendererUpdateShaderMetaHandler    \
  1380.     Q3_METHOD_TYPE('r','d','s','u')
  1381. typedef TQ3XFunctionPointer (QD3D_CALLBACK *TQ3XRendererUpdateShaderMetaHandlerMethod)(
  1382.     TQ3ObjectType                    shaderType);
  1383.     
  1384. /*
  1385.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on shaderType
  1386.  *    of kQ3ShaderTypeFoo and returns methods of type:
  1387.  */
  1388. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateShaderMethod)(
  1389.     TQ3ViewObject                    view,
  1390.     void                            *rendererPrivate,
  1391.     TQ3Object                        shaderObject);
  1392.  
  1393. /*
  1394.  *    Matrices
  1395.  */
  1396. #define kQ3XMethodTypeRendererUpdateMatrixMetaHandler                    \
  1397.     Q3_METHOD_TYPE('r','d','x','u')
  1398. typedef TQ3XMetaHandler TQ3XRendererUpdateMatrixMetaHandlerMethod;
  1399.  
  1400. /*
  1401.  *    The TQ3XRendererUpdateShaderMetaHandlerMethod switches on methods
  1402.  *    of the form kQ3MethodTypeRendererUpdateMatrixFoo:
  1403.  */
  1404. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorld                    \
  1405.     Q3_METHOD_TYPE('u','l','w','x')
  1406. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverse            \
  1407.     Q3_METHOD_TYPE('u','l','w','i')
  1408. #define kQ3XMethodTypeRendererUpdateMatrixLocalToWorldInverseTranspose    \
  1409.     Q3_METHOD_TYPE('u','l','w','t')
  1410. #define kQ3XMethodTypeRendererUpdateMatrixLocalToCamera                    \
  1411.     Q3_METHOD_TYPE('u','l','c','x')
  1412. #define kQ3XMethodTypeRendererUpdateMatrixLocalToFrustum                \
  1413.     Q3_METHOD_TYPE('u','l','f','x')
  1414. #define kQ3XMethodTypeRendererUpdateMatrixWorldToFrustum                \
  1415.     Q3_METHOD_TYPE('u','w','f','x')
  1416.  
  1417. /*
  1418.  *    and returns methods of type:
  1419.  */
  1420. typedef TQ3Status (QD3D_CALLBACK *TQ3XRendererUpdateMatrixMethod)(
  1421.     TQ3ViewObject                    view,
  1422.     void                            *rendererPrivate,
  1423.     const TQ3Matrix4x4                *matrix);
  1424.  
  1425. #ifdef __cplusplus
  1426. }
  1427. #endif    /* __cplusplus */
  1428.  
  1429. #if defined(THINK_C) || defined(__SC__)
  1430.     #pragma SC options align=reset
  1431. #elif defined(__MWERKS__)
  1432.     #pragma enumsalwaysint reset
  1433.     #pragma align_array_members reset
  1434.     #pragma options align=reset
  1435. #elif  defined(__PPCC__)
  1436.     #pragma options align=reset
  1437. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  1438.     #pragma options enum=reset
  1439. #endif
  1440.  
  1441. #endif  /*  QD3DRenderer_h  */
  1442.